/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.address.Hospital;

import java.util.List;

public interface HospitalDao extends PagingAndSortingRepository<Hospital, Long>,JpaSpecificationExecutor<Hospital>  {
	// 根據CODE查詢医院名称
	@Query("select p from Hospital p where p.code = ?1")
	Hospital findByCode(String code);

	@Query("select a from Hospital a where a.name like ?1 and a.id<?2")
	Page<Hospital> getHospitalList(String query,long id, Pageable pageRequest);

	@Query("select p from Hospital p where p.del = 1 and p.level in (1,2) ")
	List<Hospital> findAllHospital();

	@Query("select p from Hospital p where p.del = 1 and p.level = 2 ")
	List<Hospital> findAllSqHospital();

	@Query("select p from Hospital p where p.del = 1 and p.level = 2 and town = ?1")
	List<Hospital> findAreaSqHospital(String town);

	@Query("select p from Hospital p where p.del = 1 and p.level =2 ")
	List<Hospital> findHospital2();

	@Query("select p from Hospital p where p.del = 1 and p.level =2 ")
	List<Hospital> findHospitalzxFWZ();

	@Query("select p from Hospital p where p.town = ?1 and p.del='1' and p.level =2 and p.centerSite='00'")
	List<Hospital> findByTownCode(String town);
}
